<template>
  <div>
    <city-header></city-header>
    <city-search :cities='cities'></city-search>
    <city-list :cities='cities' :hotCities='hotCities' :letter='letter'></city-list>
    <city-alphabet :cities='cities' @Change='handleLetterChange'></city-alphabet>
  </div>
</template>

<script>

import CityHeader from '../city/components/Header'
import CitySearch from '../city/components/Search'
import CityList from '../city/components/List'
import CityAlphabet from '../city/components/Alphabet'

import axios from 'Axios'

export default {
  name:'City',
  components:{
    CityHeader,
    CitySearch,
    CityList,
    CityAlphabet
  },
  data(){
    return{
      cities:{},
      hotCities:[],
      letter:'',
    }
  },
  mounted(){
    this.getCityInfo()
  },
  methods:{
    handleLetterChange(letter){
      // console.log(letter);
      this.letter = letter
    },
    getCityInfo(){
      axios.get('/api/city.json')
      .then(res => {
        res = res.data;
        // console.log(res);
        if (res.ret && res.data) {
          this.cities = res.data.cities;
          this.hotCities = res.data.hotCities
          // console.log(this.cities);
        }

      })
      .catch(err => {
        console.log(err);
        
      })
    }
  }
}
</script>

<style lang="stylus" scoped>

</style>
